/**
   EMMA = Estación Meteorológica de Muestreo Automática
 
 emma_project
 Copyright (C) 2015  Rodrigo Garcia

 This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
  Dht11 temperature and humidity sensor driver
 */
#ifndef DHT11_H

#define DHT11_H

#include "sensors_flags.h" //rev
#include <util/delay.h>
#include <avr/io.h>

/// hardware
#define DHT11_PIN PINC
#define DHT11_PORT PORTC
#define DHT11_DDR DDRC

#define DHT11_WIRE 7

/// software
#define DHT11_ERROR 1

#define DHT11_HIGH() (DHT11_PORT |= 1<<DHT11_WIRE)
#define DHT11_LOW() (DHT11_PORT &= ~(1<<DHT11_WIRE))

char dht11_init(void);
void dht11_enable(void);
void dht11_disable(void);

float dht11_get_Temperature(void);
float dht11_get_RelativeHumidity(void);

unsigned char dht11_NameIndex(void);
unsigned char dht11_PhysicalPhenIndex(void);

// particular sensors functions
unsigned char dht11_read(void);

float dht11_temperature;
float dht11_RelativeHumidity;

#endif
